module Pan
  
  class AjaxCallback
    
    def initialize(block)
      @block = block
    end
    
    def invoke(session, arg)
      return unless @block
      html = HtmlCanvas.new(nil)
      @block.call(html)
      session.res.start(200) do |head,out|
        head["Content-Type"] = "text/html"
        out.write(html.to_html)
      end
    end
  end
  
end
